package bo;

import java.util.HashMap;
import java.util.Map;

public class BusinessMap {

	private static Map<String, BusinessObject> businessMap = new HashMap<String, BusinessObject>();			// 业务对象集合
	private static BusinessObject bo;																		// 业务对象
	private static Map<String, Property> propertyMap;														// 业务对象键集合
	
	private BusinessMap() {
		
	}
	
	public static Map<String, BusinessObject> getBusinessMap() {
		if(businessMap.size() == 0) {
			registerBO();
		}
		return businessMap;
	}
	
	private static void registerBO() {
		bo = new BusinessObject();
		bo.setBusinessName("日程表");
		bo.setTableName("T_BLOG_SCHEDULE");
		bo.setThumbnailName("Schedule");
		propertyMap = new HashMap<String, Property>();
		propertyMap.put("ID", new Property("主键","ID",PropertyType.STRING));
		propertyMap.put("CONTENT", new Property("内容","CONTENT",PropertyType.STRING));
		propertyMap.put("DATE", new Property("对应日期","DATE",PropertyType.STRING));
		propertyMap.put("CREATE_TIME", new Property("创建时间","CREATE_TIME",PropertyType.STRING));
		bo.setPropertyMap(propertyMap);
		businessMap.put(bo.getThumbnailName(), bo);
		
		bo = new BusinessObject();
		bo.setBusinessName("文章表");
		bo.setTableName("T_BLOG_ARTICLE");
		bo.setThumbnailName("Article");
		propertyMap = new HashMap<String, Property>();
		propertyMap.put("ID", new Property("主键","ID",PropertyType.STRING));
		propertyMap.put("TITLE", new Property("标题","TITLE",PropertyType.STRING));
		propertyMap.put("CONTENT", new Property("内容","CONTENT",PropertyType.STRING));
		propertyMap.put("ARTICLE_TYPE_ID", new Property("分类ID","CONTENT",PropertyType.STRING));
		propertyMap.put("CREATE_TIME", new Property("创建时间","CREATE_TIME",PropertyType.STRING));
		bo.setPropertyMap(propertyMap);
		businessMap.put(bo.getThumbnailName(), bo);
		
		bo = new BusinessObject();
		bo.setBusinessName("文章分类表");
		bo.setTableName("T_BLOG_ARTICLE_TYPE");
		bo.setThumbnailName("ArticleType");
		propertyMap = new HashMap<String, Property>();
		propertyMap.put("ID", new Property("主键","ID",PropertyType.STRING));
		propertyMap.put("NAME", new Property("分类名称","TITLE",PropertyType.STRING));
		propertyMap.put("CREATE_TIME", new Property("创建时间","CREATE_TIME",PropertyType.STRING));
		bo.setPropertyMap(propertyMap);
		businessMap.put(bo.getThumbnailName(), bo);
	}
}
